package com.example.hackercore.util;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedInputStream;
import java.net.URL;
import java.net.URLConnection;

/**
 * Description：
 *
 * @Author: cw
 * CreateTime：2022-10-10
 */
public class DdosUtil {

    private final static Logger log = LoggerFactory.getLogger(DdosUtil.class);


    public static void attack(String url) {
        try {
            URL uri = new URL(url);
            URLConnection conn = uri.openConnection();
            BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
            byte[] bytes = new byte[10240];
            int len = -1;
            StringBuffer sb = new StringBuffer();
            if (bis != null) {
                if ((len = bis.read()) != -1) {
                    sb.append(new String(bytes, 0, len));
                    log.info("攻击中");
                    bis.close();
                }
            }
        } catch (Exception e) {
            log.info("ddos成功", e);
        }
    }

}
